import {
    checkFive,
    isMobile,
    isEmail,
    isNumber,
    checkFloats,
    isPeopleCode,
    passPort,
    passPort2,
   // isPeopleNoOrPassPort
} from './../assets/js/reg'
export default {
    nonEmpty: (rule, val, callback) => {
        if (!val) {
            return callback('请输入内容');
        }
        callback();
    },
    phone: (rule, val, callback) => {
        if (!val) {
            return callback('请输入手机号码');
        } else {
            if (!isMobile.test(val)) {
                return callback('手机号码格式不正确');
            }
            callback();
        }
    },
    floats: (rule, val, callback) => {
        if (!val) {
            return callback('请输入数值或1-2位小数浮点数');
        } else {
            if (!checkFloats.test(val)) {
                return callback('输入类型错误，只能是浮点数');
            }
            callback();
        }
    },
    num: (rule, val, callback) => {
        if (!val) {
            return callback('请输入整数');
        } else {
            if (!isNumber.test(val)) {
                return callback('输入类型错误');
            }
            callback();
        }
    },
    email: (rule, val, callback) => {
        if (!val) {
            return callback('请输入邮箱');
        } else {
            if (!isEmail.test(val)) {
                return callback('邮箱格式不正确');
            }
            callback();
        }
    },
    checkNumber: (rule, val, callback) => {
        if (!val) {
            return callback('请输入整数');
        } else {
            if (!isNumber.test(val)) {
                return callback('请输入整数');
            } 
            callback();
        }
    },
    peopleCode: (rule, val, callback) => {
        if (!val) {
            return callback('请输入证件号码');
        } else {
            if (!isPeopleCode.test(val) ) {
                 callback('证件号码格式不正确');
            }
            callback();
        }

    }
}